C Programming
Q131.
Consider the C function given below int f(int j) { static int i = 50; int k; if (i == j) { printf("something"); k = f(i); return 0; } else return 0; } Which one of the following is TRUE?Q132.
The output of the following C program is__________. void f1(int a, int b) { int c; c=a; a=b; b=c; } void f2(int *a, int *b) { int c; c=*a; *a=*b; *b=c; } int main(){ int a=4, b=5, c=6; f1(a,b); f2(&b, &c); printf("%d",c-a-b); }Q133.
Suppose c=(c[0],...,c[k-1]) is an array of length k, where all the entries are from the set {0,1}. For any positive integers a and n, consider the following pseudocode. If k=4, c=(1,0,1,1), a=2 and n=8, then the output of DOSOMETHING(c,a,n) is _____.Q134.
What is the time complexity for the following C module? Assume that n \gt 0. int module(int n) { if (n == 1) return 1; else return (n + module(n-1)); }Q135.
Consider the following recursive C function. void get(int n) { if (n<1) return; get(n-1); get(n-3); printf("%d", n); } If get(6) function is being called in main()then how many times will the get()function be invoked before returning to the main()?Q136.
Consider the following function double f (double x) { if ( abs (x*x - 3) < 0. 01) return x; else return f (x / 2 + 1.5/x); } Give a value q (to 2 decimals) such that f(q) will return q:______Q137.
Consider the C program fragment below which is meant to divide x by y using repeated subtractions. The variables x, y, q and r are all unsigned int. while (r >= y) { r = r - y; q = q +1; } Which of the following conditions on the variables x, y, q and r before the execution of the fragment will ensure that the loop terminates in a state satisfying the condition x==(y*q+r)?Q138.
Consider the following C program main() { int x, y, m, n; scanf ("%d %d", &x, &y); /* Assume x > 0 and y > 0 */ m = x; n = y; while (m! = n) { if (m > n) m = m - n; else n = n - m; } print f ("% d", n); } The program computesQ139.
Consider the following pseudo code, where x and y are positive integers. begin q := 0 r := x while r \geq y do begin r := r - y q := q + 1 end end The post condition that needs to be satisfied after the program terminates isQ140.
Consider the following segment of C-code: int j, n; j = 1; while (j <=n) j=j*2; The number of comparisons made in the execution of the loop for any n \gt 0 is: